<?php
namespace app\index\controller;
use \think\Controller;

class CentralWeather extends Controller
{
    protected $key = '78928e706123c1a8f1766f062bc8676b' || null;
    protected $alarm = 1;
    protected $baseURL = 'http://tj.nineton.cn/Heart/index'
    protected function curl($url){
        header('Access-Control-Allow-Origin:*');  
        $curl = curl_init();
        
        curl_setopt_array($curl, array(
          CURLOPT_PORT => "8082",
          CURLOPT_URL => $url,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => "",
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 30,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => "GET",
          CURLOPT_POSTFIELDS => "",
        ));
        
        $response = curl_exec($curl);
        $err = curl_error($curl);
        
        curl_close($curl);
        
        if ($err) {
          return "cURL Error #:" . $err;
        } else {
          return $response;
        }
    }
    public function AllWeather($cityname)
    {
        $cityname = 
        $url = $this->baseURL.'/all?city='.$this->accesskey.'/'.$citycode;
        $res = $this->curl($url);
        return $res;
    }
}